package org.snail.po.service.impl;

import org.snail.po.bean.PoAttributeDO;
import org.snail.common.ExcelUtils;
import org.snail.po.service.PoFileOutputService;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Service
public class PoFileOutputServiceImpl implements PoFileOutputService {
    /**
     *用Excel生成list
     * @param file 传入的PO单Excel
     * @param request
     * @return
     */
    @Override
    public List<PoAttributeDO> getPoListByExcleImport(CommonsMultipartFile file, HttpServletRequest request) {
        String pathHome = request.getSession().getServletContext().getRealPath("upload");
        List<PoAttributeDO> poAttributeDO = ExcelUtils.getListFromExcel(file, pathHome, PoAttributeDO.class, 1);
        return poAttributeDO;
    }
}
